% function ANALYZE_CreateERSPs
% 
% %% Prepare
% delete('D:\Ralph\ECoG\CreateSPs.txt');
% diary('D:\Ralph\ECoG\CreateSPs.txt')
% 
% %% Set the desired frequency
% % freqs = 3:0.1:50;
% % freqs = 3:1:50;
% freqs = 4:0.25:200;
% % freqs = 4:2:200;
% 
% %% Primary selection
% % channels.CW = {'T07' 'T09' 'T18' 'T25' 'vT2' 'vT3' 'aT6' 'sTv1' 'sTa3' 'P02' 'P09' 'P10' 'OcO2' 'OcO3' 'OcO4' 'OcO5' 'OcO9' 'Oc10' 'Oc11'};
% % channels.DJ = {'Oc03' 'Oc08' 'Oc16' 'sT4' 'sT5' 'PO10' 'C01'};
% % channels.FG = {'P17' 'P25' 'P26' 'P27' 'P28' 'P31' 'T01' 'T03' 'T09' 'T14' 'T17' 'T18' 'IP1' 'IP2' 'IP3' 'IP8' 'IP9' 'IP10' 'IP11' 'IP14' 'IP15' 'IP16' 'F02' 'ST6' 'ST7' 'ST8'};
% % channels.JF = {'TO1' 'TO9' 'TO12' 'TO12' 'TO17' 'TO18' 'TO19' 'TO20' 'TO21' 'TO25' 'TO28' 'TO29' 'TO33' 'TO35' 'TO44' 'TO46' 'TO48' 'P05' 'P07' 'P09' 'P11' 'P16' 'ST1' 'ST7' 'ST8' 'VT1' 'VT8'};
% % channels.RV = {'C12' 'C17' 'C20' 'C21' 'C25' 'C36' 'C37' 'C38' 'C49' 'C63' 'C64' 'T04' 'T05' 'T06' 'F04' 'FB3' 'FB4' 'FB6' 'FB7' 'FB8'};
% %% Selection since 23-12-2009
% % channels.CW = {'T01' 'T06' 'T07' 'T08' 'T09' 'T10' 'T15' 'T17' 'T18' 'T19' 'T20' 'T25' 'T26' 'T27' 'T28' 'T29' 'vT2' 'vT3' 'aT6' 'sTv1' 'sTa2' 'sTa3' 'sTa4' 'P02' 'P03' 'P04' 'P09' 'P10' 'P11' 'P12' 'OcO1' 'OcO2' 'OcO3' 'OcO4' 'OcO5' 'OcO6' 'OcO7' 'OcO8' 'OcO9' 'Oc10' 'Oc11' 'Oc12' 'Oc13' 'Oc14' 'Oc15' 'Oc16'};
% % channels.DJ = {'sO1' 'sO2' 'sO7' 'sO8' 'Oc03' 'Oc06' 'Oc08' 'Oc16' 'sT3' 'sT4' 'sT5' 'PO10' 'C01' 'OL01' 'OL02' 'OL03' 'OL04' 'OL05' 'OL06' 'OL09' 'OL10' 'OL11' 'OL12' 'OL13' 'OL14' 'PO1' 'PO2' 'PO3' 'PO7' 'PO8' 'PO9' 'PO10' 'PO11' 'TO01' 'TO07' 'TO08' 'TO09' 'TO10' 'TO11' 'TO15' 'TO16' 'C04' 'C08' };
% % channels.FG = {'C02' 'C03' 'C07' 'P09' 'P10' 'P17' 'P18' 'P19' 'P20' 'P25' 'P26' 'P27' 'P28' 'P29' 'P31' 'T01' 'T02' 'T03' 'T09' 'T10' 'T14' 'T17' 'T18' 'IP1' 'IP2' 'IP3' 'IP7' 'IP8' 'IP9' 'IP10' 'IP11' 'IP14' 'IP15' 'IP16' 'F02' 'ST6' 'ST7' 'ST8'};
% % channels.JF = {'TO1' 'TO2' 'TO3' 'TO9' 'TO10' 'TO11' 'TO12' 'TO17' 'TO18' 'TO19' 'TO20' 'TO21' 'TO25' 'TO26' 'TO27' 'TO28' 'TO29' 'TO33' 'TO34' 'TO35' 'TO41' 'TO42' 'TO43' 'TO44' 'TO45' 'TO46' 'TO47' 'TO48' 'P01' 'P02' 'P03' 'P04' 'P05' 'P07' 'P09' 'P11' 'P12' 'P13' 'P14' 'P15' 'P16' 'ST1' 'ST7' 'ST8' 'VT1' 'VT8'};
% % channels.RV = {'C02' 'C03' 'C04' 'C05' 'C10' 'C11' 'C12' 'C13' 'C17' 'C18' 'C19' 'C20' 'C21' 'C25' 'C27' 'C28' 'C29' 'C34' 'C35' 'C36' 'C37' 'C38' 'C43' 'C44' 'C45' 'C49' 'C51' 'C52' 'C53' 'C54' 'C59' 'C60' 'C61' 'C62' 'C63' 'C64' 'T04' 'T05' 'T06' 'F04' 'FB3' 'FB4' 'FB6' 'FB7' 'FB8'};
% %% Selection since 04-01-2010
% % channels.CW = {'T02' 'T03' 'T04' 'T05' 'T06' 'T07' 'T08' 'T09' 'T11' 'T12' 'T13' 'T14' 'T16' 'T17' 'T18' 'T19' 'T20' 'T21' 'T22' 'T23' 'T24' 'T25' 'T26' 'T30' 'T31' 'T32' 'sTa1' 'sTa3' 'sTa4' 'sTa5' 'sTa6' 'sTa7' 'sTa8' 'P03' 'P05' 'P06' 'P07' 'P08' 'P10' 'P11' 'P12' 'P13' 'P14' 'P15' 'P16' 'OcO1' 'OcO2' 'OcO3' 'OcO4' 'OcO5' 'OcO6' 'OcO7' 'OcO8' 'OcO9' 'Oc10' 'Oc11' 'Oc12' 'Oc13' 'Oc14' 'Oc15' 'Oc16'};
% % channels.DJ = {'sO1' 'sO2' 'sO3' 'sO4' 'sO5' 'sO6' 'sO7' 'sO8' 'Oc01' 'Oc02' 'Oc04' 'Oc05' 'Oc07' 'Oc08' 'Oc09' 'Oc10' 'Oc11' 'Oc12' 'Oc13' 'Oc14' 'Oc15' 'Oc16' 'C01' 'C02' 'C03' 'C04' 'C05' 'C06' 'C07' 'C08' 'OL03' 'OL06' 'OL07' 'OL08' 'OL11' 'OL15' 'OL16' 'PO1' 'PO2' 'PO3' 'PO4' 'PO5' 'PO6' 'PO7' 'PO8' 'PO9' 'PO10' 'PO11' 'PO12' 'PO13' 'PO14' 'PO15' 'PO16' 'TO01' 'TO02' 'TO03' 'TO04' 'TO05' 'TO06' 'TO09' 'TO10' 'TO12' 'TO13' 'TO14' 'TO16' };
% % channels.FG = {'C01' 'C02' 'C03' 'C04' 'C05' 'C06' 'C07' 'C08' 'P01' 'P02' 'P03' 'P04' 'P05' 'P06' 'P07' 'P08' 'P09' 'P10' 'P11' 'P12' 'P13' 'P14' 'P15' 'P16' 'P17' 'P18' 'P19' 'P20' 'P21' 'P22' 'P23' 'P24' 'P25' 'P26' 'P27' 'P28' 'P29' 'P30' 'P31' 'P32' 'T01' 'T02' 'T03' 'T09' 'T10' 'T14' 'T17' 'T18' 'IP1' 'IP2' 'IP3' 'IP4' 'IP5' 'IP6' 'IP7' 'IP8' 'IP9' 'IP10' 'IP11' 'IP12' 'IP13' 'IP14' 'IP15' 'IP16' 'F02' 'ST6' 'ST7' 'ST8'};
% % channels.JF = {'TO2' 'TO4' 'TO5' 'TO6' 'TO7' 'TO8' 'TO10' 'TO12' 'TO13' 'TO14' 'TO15' 'TO16' 'TO17' 'TO18' 'TO19' 'TO22' 'TO23' 'TO24' 'TO26' 'TO30' 'TO31' 'TO32' 'TO34' 'TO36' 'TO37' 'TO38' 'TO39' 'TO40' 'TO41' 'TO42' 'TO43' 'TO46' 'TO47' 'TO48' 'P01' 'P06' 'P07' 'P08' 'P09' 'P10' 'P11' 'P12' 'P13' 'P14' 'P16'};
% % channels.RV = {'C01' 'C26' 'C30' 'C33' 'C41' 'C42' 'C43' 'C44' 'C45' 'C46' 'C50' 'C54' 'C55' 'C57' 'C58' 'C62' 'C63' 'C64' 'T01' 'T02' 'T03' 'T05' 'T06' 'T07' 'T08' 'IH1' 'IH2' 'IH3' 'IH4' 'IH5' 'IH6' 'IH7' 'IH8' 'IH9' 'IH10' 'IH11' 'IH12' 'IH13' 'IH14' 'IH15' 'IH16'};
% %% Extra channels to do (23-11-2010)
% channels.CW = {'T02' 'T03' 'T04' 'T05' 'T06' 'T07' 'T08' 'T09' 'T11' 'T12' 'T13' 'T14' 'T16' 'T17' 'T18' 'T19' 'T20' 'T21' 'T22' 'T23' 'T24' 'T25' 'T26' 'T30' 'T31' 'T32' 'sTa1' 'sTa3' 'sTa4' 'sTa5' 'sTa6' 'sTa7' 'sTa8' 'P03' 'P05' 'P06' 'P07' 'P08' 'P10' 'P11' 'P12' 'P13' 'P14' 'P15' 'P16' 'OcO1' 'OcO2' 'OcO3' 'OcO4' 'OcO5' 'OcO6' 'OcO7' 'OcO8' 'OcO9' 'Oc10' 'Oc11' 'Oc12' 'Oc13' 'Oc14' 'Oc15' 'Oc16'};
% channels.DJ = {'sO1' 'sO2' 'sO3' 'sO4' 'sO5' 'sO6' 'sO7' 'sO8' 'Oc01' 'Oc02' 'Oc04' 'Oc05' 'Oc07' 'Oc08' 'Oc09' 'Oc10' 'Oc11' 'Oc12' 'Oc13' 'Oc14' 'Oc15' 'Oc16' 'C01' 'C02' 'C03' 'C04' 'C05' 'C06' 'C07' 'C08' 'OL03' 'OL06' 'OL07' 'OL08' 'OL11' 'OL15' 'OL16' 'PO1' 'PO2' 'PO3' 'PO4' 'PO5' 'PO6' 'PO7' 'PO8' 'PO9' 'PO10' 'PO11' 'PO12' 'PO13' 'PO14' 'PO15' 'PO16' 'TO01' 'TO02' 'TO03' 'TO04' 'TO05' 'TO06' 'TO09' 'TO10' 'TO12' 'TO13' 'TO14' 'TO16' };
% channels.JF = {'TO2' 'TO4' 'TO5' 'TO6' 'TO7' 'TO8' 'TO10' 'TO12' 'TO13' 'TO14' 'TO15' 'TO16' 'TO17' 'TO18' 'TO19' 'TO22' 'TO23' 'TO24' 'TO26' 'TO30' 'TO31' 'TO32' 'TO34' 'TO36' 'TO37' 'TO38' 'TO39' 'TO40' 'TO41' 'TO42' 'TO43' 'TO46' 'TO47' 'TO48' 'P01' 'P06' 'P07' 'P08' 'P09' 'P10' 'P11' 'P12' 'P13' 'P14' 'P16'};
% 
% subject DJ:
%          T01 T02 T03 T04 T05 T06 T07 T08 T09 T10 T11 T12 T13 T14 T15
%          T16 T17 T18 T19 T20 T21 T22 T23 T24 T25 T26 T27 T28
%          T29 T30 T31 T32 
%          sT1 sT2 sT3 sT4 sT5 sT6 sT7 sT8
% 
% subject JF:
%          TO4 TO5 TO6 TO7 TO12 TO13 TO14 TO24 TO31 TO32 
%          TO8 TO15 TO16 TO22 TO23 TO30 
%          ST1 ST2 ST3 ST4 ST5 ST6 ST7 ST8 
%          VT1 VT2 VT3 VT4 VT5 VT6 VT7 VT8
%          
% subject CW:
%           T20 T21 T22 T23 T32 
%           T18 T19 T26 T27 T28 T29 T30 T31 
%           vT1 vT2 vT3 vT4 vT5 vT6 vT7 vT8 
%           aT1 aT2 aT3 aT4 aT5 aT6 aT7 aT8 
%           sTv1 sTv2 sTv3 sTv4 sTv5 sTv6 sTv7 sTv8 
%           sTa1 sTa2 sTa3 sTa4 sTa5 sTa6 sTa7 sTa8 
%           OcO7 OcO8 Oc15 Oc16
% 
% 
% %% Run the workload
% 
% if any(strcmp(fieldnames(channels),'CW'))
% si = SubjectInfo.Load('Subject CW');
% RunSpStuff(si, channels.CW, freqs, 85);
% end
% 
% if any(strcmp(fieldnames(channels),'DJ'))
% si = SubjectInfo.Load('Subject DJ');
% RunSpStuff(si, channels.DJ, freqs, 102);
% end
% 
% if any(strcmp(fieldnames(channels),'FG'))
% si = SubjectInfo.Load('Subject FG');
% RunSpStuff(si, channels.FG, freqs, 78);
% end
%  
% if any(strcmp(fieldnames(channels),'JF'))
% si = SubjectInfo.Load('Subject JF');
% RunSpStuff(si, channels.JF, freqs, 65);
% end
%  
% if any(strcmp(fieldnames(channels),'RV'))
% si = SubjectInfo.Load('Subject RV');
% RunSpStuff(si, channels.RV, freqs, 80);
% end
% 
% %% Finish up
% 
% diary off
% 
% setpref('Internet','SMTP_Server','smtp.uu.nl');
% setpref('Internet','E_mail','r.j.m.hendriks@uu.nl');
% sendmail({'ralph@affy.nl','r.j.m.hendriks@uu.nl','dejongmc@gmail.com'},'Matlab diary','See attachement for transscript',...
%     {'D:\Ralph\ECoG\CreateSPs.txt'});
% 
% end
% 
% 
% function [subjectinfo] = RunSpStuff(subjectinfo, channels, freqs, randomcount)
% 
% try
% %     subjectinfo = createSphereResponseERSPs(subjectinfo, channels, freqs);
% %     subjectinfo = createSphereAmbiguousResponseERSPs(subjectinfo, channels, freqs);
% %     subjectinfo = createSphereUnambiguousResponseERSPs(subjectinfo, channels, freqs);
% %     subjectinfo = createSphereUnambiguousStimulusERSPs(subjectinfo, channels, freqs);
% %     subjectinfo = createSphereResponseERSPs(subjectinfo, channels, freqs);
% %     subjectinfo = createSphereRandomSPs(subjectinfo, channels, freqs, randomcount);
%     subjectinfo = createSphereVoluntaryStimulusERSPs(subjectinfo, channels, freqs);
% %     subjectinfo = createFaceHouseResponseERSPs(subjectinfo, channels, freqs);
% %     subjectinfo = createFaceHouseAmbiguousResponseERSPs(subjectinfo, channels, freqs);
% %     subjectinfo = createFaceHouseUnambiguousResponseERSPs(subjectinfo, channels, freqs);
% %     subjectinfo = createFaceHouseUnambiguousStimulusERSPs(subjectinfo, channels, freqs);
% catch ME
%     disp('================================== Error');
%     disp(['message: ' ME.message])
%     disp('stack:')
%     for i = 1:length(ME.stack)
%         disp(ME.stack(i))
%     end
% end
% 
% end
